import { defineStore } from 'pinia'
//定义tabs的数据类型
export interface Tabs {
    title: string;
    path: string;
}
//定义state类型
export interface State {
    tabsList: Array<Tabs>
}
//定义tabs的store
export const tabsStore = defineStore('tabsStore', {
    state: (): State => {
        return {
            tabsList: []
        }
    },
    getters: {
        getTabs(state) {
            return state.tabsList
        }
    },
    actions: {
        addTab(tab: Tabs) {
            //判断是否已经存在，如果不存在，才放入
            if (this.tabsList.some(item => item.path === tab.path)) return;
            this.tabsList.push(tab)
        }
    }
})